<template>
  <base-breadcrumb :title="$route.meta.title">
    <searchData ref="searchCom" :search-data="searchOption" @search="search" @quarterRangeChange="quarterChange" />
    <a-card :bordered="false">
<!--      <title-name title="策划执行书考核季度汇总"></title-name>-->
      <list-table
        :defaultLoad="true"
        ref="table"
        :page-keys="['pageNum', 'pageSize','total']"
        size="default"
        rowKey="id"
        :columns="columns"
        :request="loadData"
        show-pagination="auto"
      >
        <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>

        <template slot="action" slot-scope="text, record">
          <span v-btnPermission="[{code:'seex_pm_056_loo_01',ident:'prma_seex'},{code:'buco_pm_056_loo_01',ident:'prma_buco'}]">
            <a @click="handleOperation('look', record)">查看</a>
          </span>

          <!-- 临时按钮 -->
          <!-- <span v-if="record.state == '1'">
            <a-divider type="vertical" />
            <a v-if="record.problem == '1'" @click="handleOperation('handelEffect', record)">处理</a>
          </span> -->
          <!-- 临时按钮 -->

          <span v-btnPermission="[{code:'seex_pm_056_exp_02',ident:'prma_seex'},{code:'buco_pm_056_exp_02',ident:'prma_buco'}]">
            <!-- 审核通过的可导出 -->
            <a-divider type="vertical" />
            <ExportMould
              :servicei-url="exportConfig.server"
              :url="exportConfig.url"
              :is-button="false"
              :request-params="{id: record.id}"
            />
          </span>
        </template>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>

import { statusList2, searchOption, columns, testData } from './model.js'
import { getPagePlanExamineQuarter, getPlanExamineQuarterExcel } from '@/api/project/projectPlanningAssessment'
import ExportMould from '@/components/ServiceExportMould'
export default {
  name: 'ProjectRecord',
  components: {
    ExportMould
  },
  data() {
    return {
      statusList2,
      searchOption,
      columns,

      exportConfig: getPlanExamineQuarterExcel(),

      queryParam: {},
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, { param: this.queryParam })

        // return new Promise((resove, reject) => {
        //   resove({
        //     code: 200,
        //     data: testData,
        //     pageNum: 1,
        //     pageSize: 10,
        //     total: 6
        //   })
        // })
        return getPagePlanExamineQuarter(requestParameters).then((res) => {
          return {code: 200, data: res.data.list, ...res.data }
        }).catch((err) => {
          return {
            code: 500,
            err
          }
        })
      },
    }
  },
  computed: {
    currentPost() {
      return this.$currentPost()
    },
  },
  created() {
      // console.log('main created')
    // console.log(mockdata)
  },
  methods: {
    quarterChange(e) {
      let value = e ? e.value : []
      this.$refs.searchCom.form.setFieldsValue({ ['startEndDate']: value })
    },
    search(e) {
      let param = this.$clone(e)
      if (param.startEndDate.length) {
        param.examineQuarterStart = param.startEndDate[0].replace('-', '')
        param.examineQuarterEnd = param.startEndDate[1].replace('-', '')
      }
      param.startEndDate && delete param.startEndDate
      if (param.grade) {
        param.gradeStart = param.grade.split(',')[0]
        param.gradeEnd = param.grade.split(',')[1]
        delete param.grade
      }
        this.queryParam = {
          ...param
        }
      this.$refs.table.refresh(true)
    },
    handleOperation(type, record = {}) {
      let { id } = record;
      this.$router.push({
        path: '/project/projectPlanningAssessment/quarterlySummary/detail',
        query: {
          type,
          id,
        }
      })
    },
  }
}
</script>

<style>
</style>
